package team.unstudio.unknownrpg_base.attribute.quality;

import java.util.HashMap;
import java.util.Map;

import indi.defoliation.unknownrpg.api.RPGItem;
import indi.defoliation.unknownrpg.api.attribute.Attribute;
import indi.defoliation.unknownrpg.api.attribute.SingleValueAttribute;

public class QualityAttribute extends Attribute implements SingleValueAttribute{
	
	private String quality="";
	
	@Override
	public Map<String, Object> serialize() {
		HashMap<String,Object> map = new HashMap<>();
		map.put(getKeyName(), quality);
		return map;
	}

	@Override
	public String getKeyName() {
		return "Quality";
	}

	@Override
	public String getDisplayName() {
		return "Quality";
	}

	@Override
	public void deserialize(Map<String, Object> map) {
		this.quality=(String) map.get(getKeyName());
	}
	
	public String getQuality(RPGItem item) {
		if(quality.equals("*"))return QualityManager.getQuality(item);
		return this.quality;
	}

}
